# 写函数，计算传入函数的字符串中,[数字]、[字母] 以及 [其他]的个数，并返回结果

def func1(value):
    zimu_count = 0
    shuzi_count = 0
    other_count = 0
    for i in value:
        if i.isnumeric():
            shuzi_count += 1
        elif i.encode('UTF-8').isalnum():
            zimu_count += 1
        else:
            other_count += 1
    print("字符串“{}”中，数字的个数为：{}，字母的个数为：{}，其它：{}".format(value, shuzi_count, zimu_count, other_count))


# str1 = 'fgh!#545坚果62gGHh'
# func1(str1)

# 写函数，函数接收四个参数分别是：姓名，性别，年龄，学历，
# 支持用户持续输入，Q或者q退出，性别默认为男，如果遇到女学生，
# 则把性别输入女，最后打印出学生的个人信息

def func2(name, age, xl, sex='男'):

    student = {"姓名":name, "性别":sex, "年龄":age, "学历":xl}
    return student

def func3():
    students = []
    while True:
        name = input("请输入学生名字：")
        if "Q" == name.upper():
            break
        sex = input("请输入学生性别：")
        if "Q" == sex.upper():
            break
        age = input("请输入学生年龄：")
        if "Q" == age.upper():
            break
        xl = input("请输入学生学历：")
        if "Q" == xl.upper():
            break
        if len(sex) == 0:
            students.append(func2(name, age, xl))
        else:
            students.append(func2(name, age, xl, sex))
    for s in students:
        print(s)


def func4():
    students = []
    while True:
        student = {}
        for key in ["姓名", "性别", "年龄", "学历"]:
            word = input("请输入学生{}：".format(key))
            student[key] = word
            if "Q" == word.upper():
                break
        if "Q" in [value.upper() for value in student.values()]:
            break
        else:
            if student.get("性别") == "":
                students.append(func2(student['姓名'], student['年龄'], student['学历']))
            else:
                students.append(func2(student['姓名'], student['年龄'], student['学历'], student['性别']))
    for i in students:
        print(i)




# func3()
func4()



